#!/usr/bin/env python

import os
import sys
from globrecursive import globrecursive

if __name__ == '__main__':
    dir = sys.argv[1]
    files = globrecursive(dir)

    for f in files:
        #if f is 'foo.bar.mp3', make NoExtension 'foo.bar' and Extension 'mp3'
        NoExtension = f.split('.')[0:-1]
        NoExtension = '.'.join(NoExtension)
        Extension   = f.split('.')[-1]
        
        for num in range(3):
            num = num + 1
            try:
                fileToRemove = NoExtension + ' ' + str(num) + '.' + Extension
                os.remove(fileToRemove)
            except:
                #if the file couldn't be removed, don't do anything
                pass 

